<!DOCTYPE html>
<html>
<head>
    <title>管理</title>
    <#include "${ctx}/include/header.ftl">
</head>
<body>
<div class="wrapper">
    <div class="main-content">
        <div class="box box-main">
            <div class="box-header">
                <div class="box-title">配置管理</div>
                <div class="box-tools pull-right">
                <@shiro.hasPermission name="configServer:config:form">
                    <a href="javascript:void(0);" onclick="tableDialog(this)" class="btn btn-default" data-type="form" data-title="新增" data-href="${ctx}/configServer/form"><i class="fa fa-plus"></i> 新增</a>
                </@shiro.hasPermission>
                </div>
            </div>
            <div class="box-body">
                <form id="searchForm" action="${ctx}/configServer/dataList" class="form-inline" onsubmit="return search();">
                    <div class="form-group">
                        <label class="control-label">应用名称：</label>
                        <div class="control-inline">
                            <select class="form-control" style="width: 200px;" name="application">
                                <option value="" selected>全部</option>
                            <#list applications as application>
                                <option value="${application.name}">${application.name?lower_case}</option>
                            </#list>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">应用环境：</label>
                        <div class="control-inline">
                            <select class="form-control" style="width: 120px;" name="profile">
                                <option value="" selected>全部</option>
                            <#list dictList("configServer.profile") as dict>
                                <option value="${dict.value}">${dict.name}</option>
                            </#list>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">参数名称：</label>
                        <div class="control-inline">
                            <input type="text" name="key" value="" class="form-control width-120" autocomplete="off" />
                        </div>
                    </div>
                    <div class="form-group">
                        <button type="submit" class="btn btn-primary btn-sm">查询</button>
                        <button type="reset" class="btn btn-default btn-sm">重置</button>
                    </div>
                </form>
                <table id="datatable" class="table table-hover table-striped table-bordered"></table>
            </div>
        </div>
    </div>
</div>
</body>
<#include "${ctx}/include/footer.ftl">
<#include "${ctx}/include/pagelist.ftl">
<script>
    $(function () {
        $("#datatable").datatable([
            {
                field: "application", title: "应用名称", align: "center", width: "200",
                formatter: function (value, row, index) {
                    return '<span class="primary">'+value+'</span>';
                }
            },
            {
                field: "profile", title: "应用环境", align: "center", width: "200",
                formatter: function (value, row, index) {
                    var val = value;
                <#list dictList("configServer.profile") as dict>
                    if('${dict.value}' == value){ val = '${dict.name}' }
                </#list>
                    return '<span class="primary">'+val+'</span>';;
                }
            },
            { field: "key", title: "参数名称", align: "center" },
            { field: "value", title: "参数值", align: "center" },
            {
                field: "status", title: "推送状态", align: "center", width: "200",
                formatter: function (value, row, index) {
                    var val = value;
                <#list dictList("configServer.sendStatus") as dict>
                    if('${dict.value}' == value){ val = '${dict.name}' }
                </#list>
                    return '<span class="primary">'+val+'</span>';;
                }
            },
            {
                title: "操作", align: "center", width: "100",
                formatter: function (value, row, index) {
                    var str = "";
                    <@shiro.hasPermission name="configServer:config:form">
                        str += '<a class="list-btn" href="javascript:void(0);" onclick="tableDialog(this)" data-type="form" data-title="修改" data-href="${ctx}/configServer/form?id='+row.id+'"><i class="fa fa-pencil"></i></a>';
                    </@shiro.hasPermission>
                    if(row.status != "0"){
                        <@shiro.hasPermission name="configServer:config:send">
                            str += '<a class="list-btn" href="javascript:void(0);" onclick="tableDialog(this)" data-type="confirm" data-title="确认推送吗" data-href="${ctx}/configServer/sendConfig?id='+row.id+'"><i class="fa fa-send-o"></i></a>';
                        </@shiro.hasPermission>
                    }
                    if(str == ""){ str = "-"; }
                    return str;
                }
            },
        ])
    })
</script>
</html>